home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat1 / command.z / command
Text File  |  1998-10-30  |  15KB  |  331 lines

  1.  
  2.  
  3.  
  4. ccccoooommmmmmmmaaaannnndddd((((1111))))                                                          ccccoooommmmmmmmaaaannnndddd((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      ccccoooommmmmmmmaaaannnndddd - execute a simple command
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ccccoooommmmmmmmaaaannnndddd [----pppp] ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee [aaaarrrrgggguuuummmmeeeennnntttt ...]
  13.      ccccoooommmmmmmmaaaannnndddd [ ----vvvv | ----VVVV ] ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee
  14.  
  15. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  16.      The ccccoooommmmmmmmaaaannnndddd utility causes the shell to treat the arguments as a simple
  17.      command, suppressing the shell function lookup.
  18.  
  19.      If the ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee is the same as the name of one of the special built-
  20.      in utilities, the special properties in the enumerated list below (See
  21.      SSSSPPPPEEEECCCCIIIIAAAALLLL BBBBUUUUIIIILLLLTTTT----IIIINNNN PPPPRRRROOOOPPPPEEEERRRRTTTTIIIIEEEESSSS) will not occur. In every other respect, if
  22.      ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee is not the name of a function, the effect of ccccoooommmmmmmmaaaannnndddd will be
  23.      the same as omitting ccccoooommmmmmmmaaaannnndddd.
  24.  
  25.      The ccccoooommmmmmmmaaaannnndddd utility also provides information concerning how a command
  26.      name will be interpreted by the shell; see ----vvvv and ----VVVV.
  27.  
  28. OOOOPPPPTTTTIIIIOOOONNNNSSSS
  29.      The ccccoooommmmmmmmaaaannnndddd utility supports the XBD specification, Utility Syntax
  30.      Guidelines.
  31.  
  32.      The following options are supported:
  33.  
  34.      ----pppp  Perform the command search using a default value for PPPPAAAATTTTHHHH that is
  35.          guaranteed to find all of the standard utilities.
  36.  
  37.      ----vvvv  Write a string to standard output that indicates the pathname or
  38.          command that will be used by the shell, in the current shell
  39.          execution environment, to invoke ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee.
  40.  
  41.              Utilities, regular built-in utilities, command_names including a
  42.              slash character, and any implementation-dependent functions that
  43.              are found using the PPPPAAAATTTTHHHH variable will be written as absolute
  44.              pathnames.
  45.  
  46.              Shell functions, special built-in utilities, regular built-in
  47.              utilities not associated with a PPPPAAAATTTTHHHH search, and shell reserved
  48.              words will be written as just their names.
  49.  
  50.              An alias will be written as a command line that represents its
  51.              alias definition.
  52.  
  53.              Otherwise, no output will be written and the exit status will
  54.              reflect that the name was not found.
  55.  
  56.      ----VVVV  Write a string to standard output that indicates how the name given
  57.          in the ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee operand will be interpreted by the shell, in the
  58.          current shell execution environment.  Although the format of this
  59.          string is unspecified, it will indicate in which of the following
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ccccoooommmmmmmmaaaannnndddd((((1111))))                                                          ccccoooommmmmmmmaaaannnndddd((((1111))))
  71.  
  72.  
  73.  
  74.          categories ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee falls and include the information stated:
  75.  
  76.              Utilities, regular built-in utilities, and any implementation-
  77.              dependent functions that are found using the PPPPAAAATTTTHHHH variable will
  78.              be identified as such and include the absolute pathname in the
  79.              string.
  80.  
  81.              Other shell functions will be identified as functions.
  82.  
  83.              Aliases will be identified as aliases and their definitions will
  84.              be included in the string.
  85.  
  86.              Special built-in utilities will be identified as special built-in
  87.              utilities.
  88.  
  89.              Regular built-in utilities not associated with a PATH search will
  90.              be identified as regular built-in utilities. (The term "regular"
  91.              need not be used.)
  92.  
  93.              Shell reserved words will be identified as reserved words.
  94.  
  95. OOOOPPPPEEEERRRRAAAANNNNDDDDSSSS
  96.      The following operands are supported:
  97.  
  98.      aaaarrrrgggguuuummmmeeeennnntttt       One of the strings treated as an argument to ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee.
  99.  
  100.      ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee   The name of a utility or a special built-in utility.
  101.  
  102. EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT VVVVAAAARRRRIIIIAAAABBBBLLLLEEEESSSS
  103.      The following environment variables affect the execution of command:
  104.  
  105.      PPPPAAAATTTTHHHH    Determine the search path used during the command search
  106.              described in Command Search and Execution, except as described
  107.              under the ----pppp option.
  108.  
  109. SSSSTTTTDDDDOOOOUUUUTTTT
  110.      When the ----vvvv option is specified, standard output is formatted as:
  111.  
  112.           "%s\n", <pathname or command>
  113.  
  114.      When the ----VVVV option is specified, standard output is formatted as:
  115.  
  116.           "%s\n", <unspecified>
  117.  
  118. EEEEXXXXIIIITTTT SSSSTTTTAAAATTTTUUUUSSSS
  119.      When the ----vvvv or ----VVVV options are specified, the following exit values are
  120.      returned:
  121.  
  122.      0     Successful completion.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ccccoooommmmmmmmaaaannnndddd((((1111))))                                                          ccccoooommmmmmmmaaaannnndddd((((1111))))
  137.  
  138.  
  139.  
  140.      >0    The ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee could not be found or an error occurred.
  141.  
  142.      Otherwise, the following exit values are returned:
  143.  
  144.      126   The utility specified by ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee was found but could not be
  145.            invoked.
  146.  
  147.      127   An error occurred in the ccccoooommmmmmmmaaaannnndddd utility or the utility specified
  148.            by ccccoooommmmmmmmaaaannnndddd____nnnnaaaammmmeeee could not be found.
  149.  
  150.      Otherwise, the exit status of ccccoooommmmmmmmaaaannnndddd will be that of the simple command
  151.      specified by the arguments to ccccoooommmmmmmmaaaannnndddd.
  152.  
  153. AAAAPPPPPPPPLLLLIIIICCCCAAAATTTTIIIIOOOONNNN UUUUSSSSAAAAGGGGEEEE
  154.      The order for command search allows functions to override regular built-
  155.      ins and path searches. This utility is necessary to allow functions that
  156.      have the same name as a utility to call the utility (instead of a
  157.      recursive call to the function).
  158.  
  159.      The system default path is available using ggggeeeettttccccoooonnnnffff; however, since
  160.      ggggeeeettttccccoooonnnnffff may need to have the PPPPAAAATTTTHHHH set up before it can be called itself,
  161.      the following can be used:
  162.  
  163.           command -p getconf _CS_PATH
  164.  
  165.      There are some advantages to suppressing the special characteristics of
  166.      special built-ins on occasion. For example:
  167.  
  168.           command exec > unwritable-file
  169.  
  170.      will not cause a non-interactive script to abort, so that the output
  171.      status can be checked by the script.
  172.  
  173.      The ccccoooommmmmmmmaaaannnndddd, eeeennnnvvvv, nnnnoooohhhhuuuupppp, ttttiiiimmmmeeee and xxxxaaaarrrrggggssss utilities have been specified to
  174.      use exit code 111122227777 if an error occurs so that applications can distinguish
  175.      "failure to find a utility" from "invoked utility exited with an error
  176.      indication".  The value 111122227777 was chosen because it is not commonly used
  177.      for other meanings; most utilities use small values for "normal error
  178.      conditions" and the values above 111122228888 can be confused with termination due
  179.      to receipt of a signal. The value 111122226666 was chosen in a similar manner to
  180.      indicate that the utility could be found, but not invoked.  Some scripts
  181.      produce meaningful error messages differentiating the 111122226666 and 111122227777 cases.
  182.      The distinction between exit codes 111122226666 and 111122227777 is based on KornShell
  183.      practice that uses 111122227777 when all attempts to exec the utility fail with
  184.      [EEEENNNNOOOOEEEENNNNTTTT], and uses 111122226666 when any attempt to exec the utility fails for any
  185.      other reason.
  186.  
  187.      Since the ----vvvv and ----VVVV options of ccccoooommmmmmmmaaaannnndddd produce output in relation to the
  188.      current shell execution environment, ccccoooommmmmmmmaaaannnndddd is generally provided as a
  189.      shell regular built-in. If it is called in a subshell or separate utility
  190.      execution environment, such as one of the following:
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. ccccoooommmmmmmmaaaannnndddd((((1111))))                                                          ccccoooommmmmmmmaaaannnndddd((((1111))))
  203.  
  204.  
  205.  
  206.           (PATH=foo command -v) nohup command -v
  207.  
  208.      it will not necessarily produce correct results. For example, when called
  209.      with nnnnoooohhhhuuuupppp or an eeeexxxxeeeecccc function, in a separate utility execution
  210.      environment, most implementations will not be able to identify aliases,
  211.      functions or special built-ins.
  212.  
  213.      Two types of regular built-ins could be encountered on a system and these
  214.      are described separately by ccccoooommmmmmmmaaaannnndddd. The description of command search in
  215.      Command Search and Execution allows for a standard utility to be
  216.      implemented as a regular built-in as long as it is found in the
  217.      appropriate place in a PPPPAAAATTTTHHHH search. So, for example, ccccoooommmmmmmmaaaannnndddd ----vvvv ttttrrrruuuueeee
  218.      might yield ////bbbbiiiinnnn////ttttrrrruuuueeee or some similar pathname. Other implementation-
  219.      dependent utilities that are not defined by this specification might
  220.      exist only as built-ins and have no pathname associated with them. These
  221.      will produce output identified as (regular) built-ins. Applications
  222.      encountering these will not be able to count on execing them, using them
  223.      with nohup, overriding them with a different PPPPAAAATTTTHHHH, and so on.
  224.  
  225. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  226.      1.  Make a version of ccccdddd that always prints out the new working directory
  227.          exactly once:
  228.  
  229.          cd() { command cd "$@" >/dev/null pwd }
  230.  
  231.      2.  Start off a "secure shell script" in which the script avoids being
  232.          spoofed by its parent:
  233.  
  234.  
  235.          IFS='
  236.          '
  237.          #    The preceding value should be <space><tab><newline>.
  238.          #    Set IFS to its default value.
  239.  
  240.          \unalias -a
  241.          #    Unset all possible aliases.
  242.          #    Note that unalias is escaped to prevent an alias
  243.          #    being used for unalias.
  244.  
  245.          unset -f command
  246.          #    Ensure command is not a user function.
  247.  
  248.          PATH="$(command -p getconf _CS_PATH):$PATH"
  249.          #    Put on a reliable PATH prefix.
  250.          #    ...
  251.  
  252.      At this point, given correct permissions on the directories called by
  253.      PPPPAAAATTTTHHHH, the script has the ability to ensure that any utility it calls is
  254.      the intended one. It is being very cautious because it assumes that
  255.      implementation extensions may be present that would allow user functions
  256.      to exist when it is invoked; this capability is not specified by this
  257.      specification, but it is not prohibited as an extension. For example, the
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. ccccoooommmmmmmmaaaannnndddd((((1111))))                                                          ccccoooommmmmmmmaaaannnndddd((((1111))))
  269.  
  270.  
  271.  
  272.      EEEENNNNVVVV variable precedes the invocation of the script with a user startup
  273.      script. Such a script could define functions to spoof the application.
  274.  
  275. SSSSPPPPEEEECCCCIIIIAAAALLLL BBBBUUUUIIIILLLLTTTT----IIIINNNN PPPPRRRROOOOPPPPEEEERRRRTTTTIIIIEEEESSSS
  276.      A syntax error in a special built-in utility may cause a shell executing
  277.      that utility to abort, while a syntax error in a regular built-in utility
  278.      will not cause a shell executing that utility to abort.  If a special
  279.      built-in utility encountering a syntax error does not abort the shell,
  280.      its exit value will be non-zero.
  281.  
  282.      Variable assignments specified with special built-in utilities will
  283.      remain in effect after the built-in completes; this is not the case with
  284.      a regular built-in or other utility.
  285.  
  286. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  287.      sssshhhh((((1111)))),,,, ttttyyyyppppeeee((((1111))))....
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.